<?php

namespace common\models\c2\entity;

use Yii;

/**
 * This is the model class for table "{{%lesson_apply}}".
 *
 * @property string $id
 * @property string $lesson_daily_id
 * @property string $user_id
 * @property string $card_hold_id
 * @property integer $status
 * @property string $created_at
 * @property string $updated_at
 */
class LessonApply extends \kzo\base\models\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%lesson_apply}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['lesson_daily_id', 'user_id', 'card_hold_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['status'], 'integer', 'max' => 4],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app.c2', 'ID'),
            'lesson_daily_id' => Yii::t('app.c2', 'Lesson Daily ID'),
            'user_id' => Yii::t('app.c2', 'User ID'),
            'card_hold_id' => Yii::t('app.c2', 'Card Hold ID'),
            'status' => Yii::t('app.c2', 'Status'),
            'created_at' => Yii::t('app.c2', 'Created At'),
            'updated_at' => Yii::t('app.c2', 'Updated At'),
        ];
    }

    /**
     * @inheritdoc
     * @return \common\models\c2\query\LessonApplyQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \common\models\c2\query\LessonApplyQuery(get_called_class());
    }

    /**
     * setup default values
     **/
    public function loadDefaultValues($skipIfSet = true)
    {
        parent::loadDefaultValues($skipIfSet);
    }

    public function getUser()
    {
        return $this->hasOne(FeUser::className(), ['id' => 'user_id']);
    }

    public function getLessonDaily()
    {
        return $this->hasOne(LessonDaily::className(), ['id' => 'lesson_daily_id']);
    }

    public function getCardHold()
    {
        return $this->hasOne(CardHold::className(), ['id' => 'card_hold_id']);
    }

}
